﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:UX="clr-namespace:MobiSms.UX;assembly=MobiSms.UX"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:viewmodel="clr-namespace:MobiSms.ViewModel;assembly=MobiSms.ViewModel"
    x:Class="MobiSms.Wasun.Views.MessageComposeView"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    Foreground="White"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">
    <!--Foreground="{StaticResource PhoneForegroundBrush}"-->
    
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush ImageSource="{Binding GlobalSettings.BackgroundImage}" Stretch="{Binding GlobalSettings.BackgroundImageStretch}" />
        </Grid.Background>
        <Grid.DataContext>
            <viewmodel:MessageComposeViewModel />
        </Grid.DataContext>

        <controls:Panorama>
            <controls:Panorama.Title>
                <StackPanel Margin="12,76,0,0" Orientation="Horizontal">
                    <Image Source="{Binding LogoUri, Mode=OneWay}"/>
                    <StackPanel VerticalAlignment="Bottom">
                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{StaticResource IDS_APP_SUBTITLE}"/>
                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="Ver 1.0 beta"/>
                    </StackPanel>
                </StackPanel>
            </controls:Panorama.Title>
            
            <controls:PanoramaItem Header="{StaticResource IDS_MESSAGE_COMPOSE}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <ScrollViewer>
                        <StackPanel>
                            <toolkit:ListPicker Header="{StaticResource IDS_MESSAGE_SERIAL}" 
                                                ItemsSource="{Binding ItemsOfSerial}" 
                                                SelectedItem="{Binding SelectedSerial, Mode=TwoWay}">
                                <toolkit:ListPicker.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding SerialNumber}"/>
                                    </DataTemplate>
                                </toolkit:ListPicker.ItemTemplate>
                                <toolkit:ListPicker.FullModeItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding SerialNumber}" Style="{StaticResource PhoneTextTitle2Style}" Margin="0,0,0,12"/>
                                    </DataTemplate>
                                </toolkit:ListPicker.FullModeItemTemplate>
                            </toolkit:ListPicker>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" 
                                           Text="{StaticResource IDS_MESSAGE_CONTENT}"/>
                                <TextBlock Style="{StaticResource PhoneTextNormalStyle}" 
                                           Text="{Binding NewMessageToSend.Content.Length}" 
                                           Grid.Column="1"/>
                            </Grid>
                            <TextBox Text="{Binding Mode=TwoWay, Path=NewMessageToSend.Content, UpdateSourceTrigger=Explicit}" 
                                     TextChanged="OnTextBoxTextChanged"
                                     AcceptsReturn="True" 
                                     TextWrapping="Wrap"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" 
                                       Text="{StaticResource IDS_MESSAGE_EXTENSION}"/>
                            <TextBox InputScope="Number" 
                                     Text="{Binding NewMessageToSend.Extension, Mode=TwoWay}"/>
                            <CheckBox Content="{StaticResource IDS_MESSAGE_USESIGNATURE}" 
                                      IsChecked="{Binding NewMessageToSend.IsSign, Mode=TwoWay}"/>
                            <TextBox Text="{Binding NewMessageToSend.Signature, Mode=TwoWay}" 
                                     Visibility="{Binding NewMessageToSend.IsSign, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" 
                                       Text="{StaticResource IDS_MESSAGE_CHARGECOUNT}"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" 
                                       Text="{Binding TotleSendCount}" />
                        </StackPanel>
                    </ScrollViewer>
                    <StackPanel Grid.Column="1" VerticalAlignment="Bottom">
                        <UX:UXPathButton IconPath="{StaticResource PATH_ICON_CLOSE}" 
                                         Command="{Binding CancelCommand}"
                                         Padding="14" 
                                         Margin="12,0,0,12"/>
                        <UX:UXPathButton IconPath="{StaticResource PATH_ICON_SUBMIT}" 
                                         Margin="12,0,0,12" 
                                         Command="{Binding SubmitCommand, Mode=OneWay}"/>
                    </StackPanel>
                </Grid>
            </controls:PanoramaItem>

            <controls:PanoramaItem Header="{StaticResource IDS_MESSAGE_MOBILES}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>

                    <TextBox Text="{Binding NewContactToAdd.Mobile, Mode=TwoWay, UpdateSourceTrigger=Default}" InputScope="Number"/>
                    <UX:UXPathButton Grid.Column="1" StrokeThickness="3" IconPath="{StaticResource PATH_ICON_CLOSE}" Angle="45" Command="{Binding AddContactCommand, Mode=OneWay}"/>

                    <ListBox Grid.Row="1" ItemsSource="{Binding ItemsOfContact}" SelectionMode="Multiple">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListBoxItem">
                                            <StackPanel Grid.Column="1">
                                                <StackPanel Orientation="Horizontal">
                                                    <CheckBox x:Name="checkBox" 
                                                              VerticalAlignment="Top" 
                                                              Tag="{Binding Mobile}" 
                                                              IsChecked="{Binding IsSelected, Mode=TwoWay}"/>
                                                    <TextBlock Style="{StaticResource PhoneTextTitle2Style}" 
                                                               Text="{Binding Mobile}" 
                                                               Foreground="{StaticResource PhoneChromeBrush}" 
                                                               VerticalAlignment="Center"/>
                                                </StackPanel>

                                                <StackPanel Orientation="Horizontal">
                                                    <Grid Width="68"/>
                                                    <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                                                               Text="{Binding Name}"/>
                                                </StackPanel>
                                                    
                                            </StackPanel>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                    </ListBox>
                    
                    <StackPanel Grid.Column="1" Grid.Row="1" VerticalAlignment="Bottom">
                        <UX:UXCheckBox IconPath="{StaticResource PATH_ICON_CONTACTBOOK}" IsChecked="{Binding DisplayContactBook,Mode=TwoWay}" Margin="0,0,0,12"/>
                        <UX:UXPathButton IconPath="{StaticResource PATH_ICON_CLEAN}" Margin="0,0,0,12" Command="{Binding CleanCommand}"/>
                        <UX:UXPathButton IconPath="{StaticResource PATH_ICON_SELECTED}" Command="{Binding SelectedCommand, Mode=OneWay}"/>
                        <UX:UXPathButton IconPath="{StaticResource PATH_ICON_UNSELECTED}" Command="{Binding UnselectedCommand, Mode=OneWay}" Margin="0,12"/>
                    </StackPanel>
                </Grid>
            </controls:PanoramaItem>
        </controls:Panorama>
        
        <Grid Background="{StaticResource PhoneSubtleBrush}" Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}">
            <ProgressBar IsIndeterminate="True"/>
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>